<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<jsp:include page="/jsp/loginCheck.jsp" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Usuários</title>
	<link href="../css/estiloframes.css" rel="stylesheet" type="text/css" />
	<link href="../css/cmxform.css" rel="stylesheet" type="text/css" />
	
	<script type="text/javascript" src="../js/jquery.js"></script>
	<script type="text/javascript" src="../js/jquery.validate.js"></script>
	<script type="text/javascript" src="../js/jquery.metadata.js"></script>
	
	<script type="text/javascript">
	$(document).ready(function() {
		$("#form").validate({meta: "validate"});
	});
	</script>

</head>



<body>
	<div id="corpo">
		<br />
		<p style="font-weight:bold;">
			<s:if test="functionType == 'cadastro'">
				<s:text name="Cadastro de Usuário"/>
			</s:if>
			<s:else>
				<s:text name="Alteração de Usuário"/>				
			</s:else>
		</p>
		<s:form action="User" id="form" cssClass="cmxform">
			<s:if test="functionType == 'update'">
				<s:hidden name="user.id" value="%{user.id}"/>
			</s:if>	
			 
			<div style="position:absolute; left: 25px;">
				<table align="center" width="625" border="0">
				  <tr>
				    <td width="265">
				      <div align="right"><s:text name="Nome:"/></div></td>
				    <td><div align="left"><s:textfield id="cname" name="user.usuario" cssClass="{validate:{required:true, messages:{required:'  Por favor insira seu nome!'}}}" maxlength="45" /></div></td>
				  </tr>
				  <tr>
				    <td width="265">
				      <div align="right"><s:text name="Código do Pesquisador:"/></div></td>
				    <td><div align="left"><s:textfield id="ccodigo" name="user.codigo_usuario" cssClass="{validate:{required:true, messages:{required:'  Por favor insira o Código do Usuário!'}}}" maxlength="8" /></div></td>
				  </tr>
				  <tr>
				    <td><div align="right"><s:text name="E-mail:"/></div></td>
				    <td><div align="left"><s:textfield name="user.email" cssClass="{validate:{required:true, email:true, messages:{required:'  favor insira seu E-mail!', email:'  Por favor insira um email válido!'}}}" maxlength="100" /></div></td>
				  </tr>
				  <tr>
				    <td><div align="right"><s:text name="Senha:"/></div></td>
				    <td><div align="left"><s:password name="user.senha" cssClass="{validate:{required:true, messages:{required:'  Por favor insira sua senha!'}}}" maxlength="45" /></div></td>
				  </tr>
				  <tr>
				    <td><div align="right"><s:text name="Confirmar Senha:"/></div></td>
				    <td><div align="left"><s:password name="user.confirmarSenha" cssClass="{validate:{required:true, messages:{required:'  Por favor confirme sua senha!'}}}" maxlength="45" /></div></td>
				  </tr>
				  <tr>
				    <td><div align="right"><s:text name="Perfil:"/></div></td>
				    <td><div align="left"><s:select name="user.idPerfil" label="Perfil" list="listPerfil" listKey="index" listValue="value" headerKey="-1" headerValue="Perfil" cssClass="textboxes"/></div></td>			   
				  </tr>
				   <tr>
				    <td><div align="right"><s:text name="Grupo:"/></div></td>
				    <td><div align="left"><s:select name="user.idGrupo" label="Grupos" list="listGrupo" listKey="index" listValue="value" headerKey="-1" headerValue="Grupos" cssClass="textboxes"/></div></td>
				  </tr>	
				  <tr>
				    <td> </td>
				    <td>
				    	<div align="left">
						    <s:if test="functionType == 'cadastro'">
								<s:hidden name="functionType" value="%{functionType}" />
								<p><s:submit action="insertUser" type="image" src="../images/btn/salvar.png" cssClass="clicavel" align="center"/><s:text name="Salvar"/></p>
							</s:if>
							<s:else>
								<s:hidden name="functionType" value="%{functionType}" />
								<p><s:submit action="updateUser" type="image" src="../images/btn/salvar.png" cssClass="clicavel" align="center"/><s:text name="Salvar"/></p>
							</s:else>
						</div>
				    </td>
				  </tr>			   
				</table>
			</div>			
			
		</s:form>
	</div>
</body>
</html>
